package com.mlyol.singleton;

public class Demo6 {
    private static volatile Demo6 instance;

    private Demo6() {

    }

    public static void main(String[] args) {
        Demo6 instance = Demo6.getInstance();
        Demo6 instance1 = Demo6.getInstance();
        System.out.println(instance == instance1);
    }

    public static Demo6 getInstance() {
        if (instance == null) {
            synchronized (Demo6.class) {
                if (instance == null) {
                    instance = new Demo6();
                }
            }
        }
        return instance;
    }

}
